const path = require("path");
const webpack = require("webpack");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const nodeExternals = require("webpack-node-externals");
const BasicPlugin = require("./plugins/index");
const AuthorPlugin = require("./plugins/author");
const jiaPlugin = require("./plugins/jia");
module.exports = {
  target: "node",
  entry: {
    main: ["./src/server.js"],
  },
  mode: "production",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "encryption_build.js",
    publicPath: "/",
  },
  externals: [nodeExternals()],
  resolve: {
    extensions: [".js"],
    // fallback: {
    //   fs: true,
    //   crypto: require.resolve("crypto-browserify"),
    // },
  },
  plugins: [
    // new webpack.optimize.OccurrenceOrderPlugin(),
    // new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    new NodePolyfillPlugin(),
    new AuthorPlugin({
      name: "liuyong-byte",
      email: "1256230450@qq.com",
    }),
    new BasicPlugin(),
    new jiaPlugin({ sourceMap: true }),
  ],
};
